﻿CREATE TABLE [dbo].[Addresses]
(
	[Id]			[UNIQUEIDENTIFIER]		NOT NULL,
	[Type]			[CHAR](1)				NOT NULL,
	[TenantId]		[BIGINT]				NULL,
	[Line1]			[VARCHAR](256)			NOT NULL,
	[Line2]			[VARCHAR](256)			NOT NULL,
	[Line3]			[VARCHAR](256)			NOT NULL,
	[City]			[VARCHAR](256)			NOT NULL,
	[State]			[VARCHAR](256)			NOT NULL,
	[CountryCode]	[VARCHAR](256)			NOT NULL,
	[PostalCode]	[VARCHAR](256)			NOT NULL,
	[CreatedAt]		[DATETIME]				NOT NULL,
	CONSTRAINT PK_Address PRIMARY KEY ([Id]),
	CONSTRAINT FK_Address_Tenants FOREIGN KEY ([TenantId]) REFERENCES [dbo].[Tenants]([Id]),
	CONSTRAINT CK_Address_Type CHECK ([Type] = 'B' /* Billing */ OR [Type] = 'C' /* Contact */)
)
